<?php


namespace app\bonus\model;


use app\common\model\BaseModel;
use think\Model;

class WapCoupon extends Model
{
    /**
     * 获取类别
     * @param array $wdata
     * @return \think\Paginator
     * @throws \think\exception\DbException
     */
    public static function getListData($wdata =[]){
        return self::alias("c")->field("c.*,s.name as shop_name")
            ->join('wap_shop s','c.shop_id = s.id','left')
            ->where($wdata)
            ->paginate(15);
    }

    public static function getDataOne($wdata){
        $data = self::where($wdata)->field(true)->find();
        if($data) {
            $data = $data->toArray();
            $data['start_time'] = $data['start_time']? str_replace(' ','T',date("Y-m-d H:i",($data['start_time']))):"";
            $data['end_time'] = $data['end_time']? str_replace(' ','T',date("Y-m-d H:i",($data['end_time']))):"";
        }
        return $data;
    }
}